Repository navigation
Settings sweeps read by key, and the runs sweeps reach every run - #514
Merged
Merged
Conversation
The settings table holds analytics, markers and every team's settings together, well over 100,000 items on a busy install. Two sweeps found their records by scanning all of it: the hourly automatic-fix sweep and the 15-minute name check. A shared index partition (INDEX#<name>) now names each record; writers add to it, readers get each record by key, drop members whose record is gone, and rebuild the index from one full scan at most once a day. The PR-outcome sweeps scanned the runs table from the first page each tick with a 20-page cap, so runs past the cap were never reached once the table grew. They now save where the cap stopped and carry on from there. The install's only-team lookup read one 50-item page of the teams table, which also holds ticket locks; it now reads every page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit of every
.scan()after the review sweeps were found reading none of the configs: their capped scan of the settings table stopped before reaching them. This fixes the other scans that read the whole settings table on a schedule, or that stop at a cap and can miss records.Changes
common::settings_index: an index partitionINDEX#<name>in the settings table naming each record of one kind. Readers query it and get each record by key, drop members whose record is gone, and rebuild it from one fully paged scan when it was never built or is over a day old. Writers add the member when they save.log_findings::teams_with_autofix, hourly): reads teams from theLOG_AUTOFIXindex. Before, every run scanned the whole settings table. The gateway adds the team when the setting is saved.hybrid_name_check::claims, every 15 minutes, hosted): reads reservations from theHYBRIDNAMEindex. The gateway adds the name when it is claimed.pr_outcomes::find_runs): the 20-page cap now saves where it stopped (SYSTEM/SCAN_CURSOR#<sweep>) and the next tick carries on from there; reaching the end starts over. Before, each tick restarted at page 1, so runs past page 20 were never reconciled. Each tick logs pages read, runs found and whether it reached the end.hybrid_install::only_team): reads every page. It read one 50-item page of the teams table, which also holds ticket locks, so it could miss the team record or see only one of several teams.teams_with_autofixhybrid_name_check::claimspr_outcomes::find_runshybrid_install::only_teamready::sweepweekly_summary::runaws_permissions::accounts_by_teamemail_settings::peoplesetup_checks::setup_openadmin::scan_allsign_in::ensure_orgVerification
cargo test -p common --lib: 1,523 passed.cargo test -p worker pr_outcomes: 10 passed.cargo test -p worker name_index: 2 passed.cargo test -p gateway only_team: 2 passed.cargo fmtandcargo clippy -p common -p gateway -p worker --all-targets -D warnings: clean.